﻿using System;
using System.Collections.Specialized;
using System.ComponentModel;
using System.IO;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SystemX.WebControls.XPaging;

namespace SystemX.WebControls
{
	/// <summary>
	/// ASPNET Extensive Pager control
	/// </summary>
    [DefaultEvent("PageChanged"), 
	ToolboxData("<{0}:XPager runat=server></{0}:XPager>"), 
	ParseChildren(false), 
	PersistChildren(false), 
	XDescription("desc_XPager"), 
	DefaultProperty("PageSize"), 
	AspNetHostingPermission(SecurityAction.Demand, Level=AspNetHostingPermissionLevel.Minimal)]
    public class XPager : Panel, INamingContainer, IPostBackEventHandler, IPostBackDataHandler
	{

		#region private member variables
		private XPager cloneFrom;
        private string cssClassName;
        private string currentUrl;
        private static readonly object EventPageChanged = new object();
        private static readonly object EventPageChanging = new object();
        private string inputPageIndex;
        private string queryString;
        private string VersionNumber =typeof(XPager).Assembly.GetName().Version.ToString();
		#endregion

		#region events
		public event EventHandler PageChanged
        {
            add
            {
                base.Events.AddHandler(EventPageChanged, value);
            }
            remove
            {
                base.Events.RemoveHandler(EventPageChanged, value);
            }
        }

        public event PageChangingEventHandler PageChanging
        {
            add
            {
                base.Events.AddHandler(EventPageChanging, value);
            }
            remove
            {
                base.Events.RemoveHandler(EventPageChanging, value);
            }
		}
		#endregion

		#region base overrides
		protected override void AddAttributesToRender(HtmlTextWriter writer)
        {
            if ((this.Page != null) && !this.UrlPaging)
            {
                this.Page.VerifyRenderingInServerForm(this);
            }
            base.AddAttributesToRender(writer);
		}

		protected override void OnInit(EventArgs e)
		{
			base.OnInit(e);
			if ((this.CloneFrom != null) && (string.Empty != this.CloneFrom.Trim()))
			{
				XPager pager = this.Parent.FindControl(this.CloneFrom) as XPager;
				if (pager == null)
				{
					string str = ResReader.GetString("clonefromexeption") ?? "The control \" %controlID% \" does not exist or is not of type XPager!";
					throw new ArgumentException(str.Replace("%controlID%", this.CloneFrom), "CloneFrom");
				}
				if ((pager.cloneFrom != null) && (this == pager.cloneFrom))
				{
					string message = ResReader.GetString("recusiveclonefrom") ?? "Invalid value for the CloneFrom property, XPager controls can not to be cloned recursively!";
					throw new ArgumentException(message, "CloneFrom");
				}
				this.cloneFrom = pager;
				this.CssClass = this.cloneFrom.CssClass;
				this.Width = this.cloneFrom.Width;
				this.Height = this.cloneFrom.Height;
				this.HorizontalAlign = this.cloneFrom.HorizontalAlign;
				this.BackColor = this.cloneFrom.BackColor;
				this.BackImageUrl = this.cloneFrom.BackImageUrl;
				this.BorderColor = this.cloneFrom.BorderColor;
				this.BorderStyle = this.cloneFrom.BorderStyle;
				this.BorderWidth = this.cloneFrom.BorderWidth;
				this.Font.CopyFrom(this.cloneFrom.Font);
				this.ForeColor = this.cloneFrom.ForeColor;
				this.EnableViewState = this.cloneFrom.EnableViewState;
				this.Enabled = this.cloneFrom.Enabled;
			}
		}

		protected override void OnLoad(EventArgs e)
		{
			if (this.UrlPaging)
			{
				this.currentUrl = this.Page.Request.Path;
				this.queryString = this.Page.Request.ServerVariables["Query_String"];
				if (!this.Page.IsPostBack && (this.cloneFrom == null))
				{
					int num;
					int.TryParse(this.Page.Request.QueryString[this.UrlPageIndexName], out num);
					if (num <= 0)
					{
						num = 1;
					}
					else if (this.ReverseUrlPageIndex)
					{
						num = (this.PageCount - num) + 1;
					}
					PageChangingEventArgs args = new PageChangingEventArgs(num);
					this.OnPageChanging(args);
				}
			}
			else
			{
				this.inputPageIndex = this.Page.Request.Form[String.Format("{0}_input", this.UniqueID)];
			}
			base.OnLoad(e);
		}

		protected override void OnPreRender(EventArgs e)
		{
			if ((this.PageCount > 1) && ((this.ShowPageIndexBox == ShowPageIndexBox.Always) || ((this.ShowPageIndexBox == ShowPageIndexBox.Auto) && (this.PageCount >= this.ShowBoxThreshold))))
			{
				StringBuilder builder = new StringBuilder("<script type=\"text/javascript\">\n//<![CDATA[\n");
				if (this.UrlPaging)
				{
					builder.Append("function XPagerTo(boxEl){if(boxEl!=null){var pi;if(boxEl.tagName==\"SELECT\")");
					builder.Append("{pi=boxEl.options[boxEl.selectedIndex].value;}else{pi=boxEl.value;};");
					if (string.IsNullOrEmpty(this.UrlPagingTarget))
					{
						builder.Append("location.href=\"").Append(this.GetHrefString(-1)).Append("\"");
					}
					else
					{
						builder.Append("window.open(\"").Append(this.GetHrefString(-1)).Append("\",\"").Append(this.UrlPagingTarget).Append("\")");
					}
					builder.Append(";};};\n");
				}
				if (this.PageIndexBoxType == PageIndexBoxType.TextBox)
				{
					string str = ResReader.GetString("checkinputscript");
					if (str != null)
					{
						str = str.Replace("%PageIndexOutOfRangeErrorMessage%", this.PageIndexOutOfRangeErrorMessage).Replace("%InvalidPageIndexErrorMessage%", this.InvalidPageIndexErrorMessage);
					}
					builder.Append(str).Append("\n");
					string str2 = ResReader.GetString("keydownscript");
					builder.Append(str2);
				}
				builder.Append("\n//]]>\n</script>");
				Type type = base.GetType();
				ClientScriptManager clientScript = this.Page.ClientScript;
				if (!clientScript.IsClientScriptBlockRegistered(type, "xpager_script"))
				{
					clientScript.RegisterClientScriptBlock(type, "xpager_script", builder.ToString());
				}
			}
			base.OnPreRender(e);
		}



		public override void RenderBeginTag(HtmlTextWriter writer)
		{
			bool flag = (this.PageCount > 1) || ((this.PageCount <= 1) && this.AlwaysShow);
			//TODO:put copyright info here
			if (!flag)
			{
				writer.Write("<!--");
				writer.Write(ResReader.GetString("autohideinfo"));
				writer.Write("-->");
			}
			else
			{
				base.RenderBeginTag(writer);
			}
		}

		protected override void RenderContents(HtmlTextWriter writer)
		{
			if ((this.PageCount > 1) || this.AlwaysShow)
			{
				writer.Indent = 0;
				if (this.ShowCustomTip != ShowCustomTip.Never)
				{
					if (this.LayoutType == LayoutType.Table)
					{
						writer.AddAttribute(HtmlTextWriterAttribute.Width, "100%");
						writer.AddAttribute(HtmlTextWriterAttribute.Style, base.Style.Value);
						if (this.Height != Unit.Empty)
						{
							writer.AddStyleAttribute(HtmlTextWriterStyle.Height, this.Height.ToString());
						}
						writer.AddAttribute(HtmlTextWriterAttribute.Border, "0");
						writer.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "0");
						writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0");
						writer.RenderBeginTag(HtmlTextWriterTag.Table);
						writer.RenderBeginTag(HtmlTextWriterTag.Tr);
					}
					if (this.ShowCustomTip == ShowCustomTip.Left)
					{
						this.RenderCustomInfoSection(writer);
						this.RenderNavigationSection(writer);
					}
					else
					{
						this.RenderNavigationSection(writer);
						this.RenderCustomInfoSection(writer);
					}
					if (this.LayoutType == LayoutType.Table)
					{
						writer.RenderEndTag();
						writer.RenderEndTag();
					}
				}
				else
				{
					this.RenderPagingElements(writer);
				}
			}
		}
		public override void RenderEndTag(HtmlTextWriter writer)
		{
			if ((this.PageCount > 1) || ((this.PageCount <= 1) && this.AlwaysShow))
			{
				base.RenderEndTag(writer);
			}
			//TODO:put copyright info here
		}
		#endregion

		#region helper methods

		private void AddHyperlinkTarget(HtmlTextWriter writer)
        {
            if (!string.IsNullOrEmpty(this.UrlPagingTarget))
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Target, this.UrlPagingTarget);
            }
        }

        private static void addMoreListItem(HtmlTextWriter writer, int pageIndex)
        {
            writer.Write("<option value=\"");
            writer.Write(pageIndex);
            writer.Write("\">......</option>");
        }

        private void AddPagingButtonLayoutTag(HtmlTextWriter writer)
        {
            if (this.PagingButtonLayoutType == PagingButtonLayoutType.UnorderedList)
            {
                writer.RenderBeginTag(HtmlTextWriterTag.Li);
            }
            else if (this.PagingButtonLayoutType ==PagingButtonLayoutType.Span)
            {
                writer.RenderBeginTag(HtmlTextWriterTag.Span);
            }
        }

        private void AddToolTip(HtmlTextWriter writer, int pageIndex)
        {
            if (this.ShowNavigationToolTip)
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Title, string.Format(this.NavigationToolTipTextFormatString, pageIndex));
            }
        }

        private string BuildUrlString(string sk, string sv)
        {
            StringBuilder builder = new StringBuilder(80);
            bool flag = false;
            int num = (this.queryString != null) ? this.queryString.Length : 0;
            for (int i = 0; i < num; i++)
            {
                string str2;
                int startIndex = i;
                int num4 = -1;
                while (i < num)
                {
                    char ch = this.queryString[i];
                    if (ch == '=')
                    {
                        if (num4 < 0)
                        {
                            num4 = i;
                        }
                    }
                    else if (ch == '&')
                    {
                        break;
                    }
                    i++;
                }
                string str = null;
                if (num4 >= 0)
                {
                    str = this.queryString.Substring(startIndex, num4 - startIndex);
                    str2 = this.queryString.Substring(num4 + 1, (i - num4) - 1);
                }
                else
                {
                    str2 = this.queryString.Substring(startIndex, i - startIndex);
                }
                builder.Append(str).Append("=");
                if (str == sk)
                {
                    flag = true;
                    builder.Append(sv);
                }
                else
                {
                    builder.Append(str2);
                }
                builder.Append("&");
            }
            if (!flag)
            {
                builder.Append(sk).Append("=").Append(sv);
            }
            builder.Insert(0, "?").Insert(0, Path.GetFileName(this.currentUrl));
            return builder.ToString().Trim(new char[] { '&' });
        }

        private static NameValueCollection ConvertQueryStringToCollection(string s)
        {
            NameValueCollection values = new NameValueCollection();
            int num = (s != null) ? s.Length : 0;
            for (int i = 0; i < num; i++)
            {
                string str2;
                int startIndex = i;
                int num4 = -1;
                while (i < num)
                {
                    char ch = s[i];
                    if (ch == '=')
                    {
                        if (num4 < 0)
                        {
                            num4 = i;
                        }
                    }
                    else if (ch == '&')
                    {
                        break;
                    }
                    i++;
                }
                string name = null;
                if (num4 >= 0)
                {
                    name = s.Substring(startIndex, num4 - startIndex);
                    str2 = s.Substring(num4 + 1, (i - num4) - 1);
                }
                else
                {
                    str2 = s.Substring(startIndex, i - startIndex);
                }
                values.Add(name, str2);
                if ((i == (num - 1)) && (s[i] == '&'))
                {
                    values.Add(null, string.Empty);
                }
            }
            return values;
        }

        private void CreateMoreButton(HtmlTextWriter writer, int pageIndex)
        {
            this.AddPagingButtonLayoutTag(writer);
            this.writeSpacingStyle(writer);
            this.WriteCssClass(writer);
            writer.AddAttribute(HtmlTextWriterAttribute.Href, this.GetHrefString(pageIndex));
            this.AddToolTip(writer, pageIndex);
            this.AddHyperlinkTarget(writer);
            writer.RenderBeginTag(HtmlTextWriterTag.A);
            if ((this.PagingButtonType == PagingButtonType.Image) && (this.MoreButtonType == PagingButtonType.Image))
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Src, this.ImagePath + "more" + this.ButtonImageNameExtension + this.ButtonImageExtension);
                writer.AddAttribute(HtmlTextWriterAttribute.Border, "0");
                if (this.ButtonImageAlign != ImageAlign.NotSet)
                {
                    writer.AddAttribute(HtmlTextWriterAttribute.Align, this.ButtonImageAlign.ToString());
                }
                writer.RenderBeginTag(HtmlTextWriterTag.Img);
                writer.RenderEndTag();
            }
            else
            {
                writer.Write("...");
            }
            writer.RenderEndTag();
            if (this.PagingButtonLayoutType != PagingButtonLayoutType.None)
            {
                writer.RenderEndTag();
            }
        }

        private void CreateNavigationButton(HtmlTextWriter writer, string btnname)
        {
            if ((this.ShowFirstLast || ((btnname != "first") && (btnname != "last"))) && (this.ShowPrevNext || ((btnname != "prev") && (btnname != "next"))))
            {
                string str;
                bool flag;
                int num;
                this.AddPagingButtonLayoutTag(writer);
                bool flag2 = (this.PagingButtonType ==PagingButtonType.Image) && (this.NavigationButtonType == PagingButtonType.Image);
                if ((btnname == "prev") || (btnname == "first"))
                {
                    flag = (this.CurrentPageIndex <= 1) | !this.Enabled;
                    if (!this.ShowDisabledButtons && flag)
                    {
                        return;
                    }
                    num = (btnname == "first") ? 1 : (this.CurrentPageIndex - 1);
                    this.writeSpacingStyle(writer);
                    if (flag2)
                    {
                        if (!flag)
                        {
                            writer.AddAttribute(HtmlTextWriterAttribute.Href, this.GetHrefString(num));
                            this.AddToolTip(writer, num);
                            this.AddHyperlinkTarget(writer);
                            writer.RenderBeginTag(HtmlTextWriterTag.A);
                            writer.AddAttribute(HtmlTextWriterAttribute.Src, this.ImagePath + btnname + this.ButtonImageNameExtension + this.ButtonImageExtension);
                            writer.AddAttribute(HtmlTextWriterAttribute.Border, "0");
                            if (this.ButtonImageAlign != ImageAlign.NotSet)
                            {
                                writer.AddAttribute(HtmlTextWriterAttribute.Align, this.ButtonImageAlign.ToString());
                            }
                            writer.RenderBeginTag(HtmlTextWriterTag.Img);
                            writer.RenderEndTag();
                            writer.RenderEndTag();
                        }
                        else
                        {
                            writer.AddAttribute(HtmlTextWriterAttribute.Src, this.ImagePath + btnname + this.DisabledButtonImageNameExtension + this.ButtonImageExtension);
                            writer.AddAttribute(HtmlTextWriterAttribute.Border, "0");
                            if (this.ButtonImageAlign != ImageAlign.NotSet)
                            {
                                writer.AddAttribute(HtmlTextWriterAttribute.Align, this.ButtonImageAlign.ToString());
                            }
                            writer.RenderBeginTag(HtmlTextWriterTag.Img);
                            writer.RenderEndTag();
                        }
                    }
                    else
                    {
                        str = (btnname == "prev") ? this.PrevPageText : this.FirstPageText;
                        if (flag)
                        {
                            writer.AddAttribute(HtmlTextWriterAttribute.Disabled, "disabled");
                        }
                        else
                        {
                            this.WriteCssClass(writer);
                            this.AddToolTip(writer, num);
                            this.AddHyperlinkTarget(writer);
                            writer.AddAttribute(HtmlTextWriterAttribute.Href, this.GetHrefString(num));
                        }
                        writer.RenderBeginTag(HtmlTextWriterTag.A);
                        writer.Write(str);
                        writer.RenderEndTag();
                    }
                }
                else
                {
                    flag = (this.CurrentPageIndex >= this.PageCount) | !this.Enabled;
                    if (!this.ShowDisabledButtons && flag)
                    {
                        return;
                    }
                    num = (btnname == "last") ? this.PageCount : (this.CurrentPageIndex + 1);
                    this.writeSpacingStyle(writer);
                    if (flag2)
                    {
                        if (!flag)
                        {
                            writer.AddAttribute(HtmlTextWriterAttribute.Href, this.GetHrefString(num));
                            this.AddToolTip(writer, num);
                            this.AddHyperlinkTarget(writer);
                            writer.RenderBeginTag(HtmlTextWriterTag.A);
                            writer.AddAttribute(HtmlTextWriterAttribute.Src, this.ImagePath + btnname + this.ButtonImageNameExtension + this.ButtonImageExtension);
                            writer.AddAttribute(HtmlTextWriterAttribute.Border, "0");
                            if (this.ButtonImageAlign != ImageAlign.NotSet)
                            {
                                writer.AddAttribute(HtmlTextWriterAttribute.Align, this.ButtonImageAlign.ToString());
                            }
                            writer.RenderBeginTag(HtmlTextWriterTag.Img);
                            writer.RenderEndTag();
                            writer.RenderEndTag();
                        }
                        else
                        {
                            writer.AddAttribute(HtmlTextWriterAttribute.Src, this.ImagePath + btnname + this.DisabledButtonImageNameExtension + this.ButtonImageExtension);
                            writer.AddAttribute(HtmlTextWriterAttribute.Border, "0");
                            if (this.ButtonImageAlign != ImageAlign.NotSet)
                            {
                                writer.AddAttribute(HtmlTextWriterAttribute.Align, this.ButtonImageAlign.ToString());
                            }
                            writer.RenderBeginTag(HtmlTextWriterTag.Img);
                            writer.RenderEndTag();
                        }
                    }
                    else
                    {
                        str = (btnname == "next") ? this.NextPageText : this.LastPageText;
                        if (flag)
                        {
                            writer.AddAttribute(HtmlTextWriterAttribute.Disabled, "disabled");
                        }
                        else
                        {
                            this.WriteCssClass(writer);
                            this.AddToolTip(writer, num);
                            writer.AddAttribute(HtmlTextWriterAttribute.Href, this.GetHrefString(num));
                            this.AddHyperlinkTarget(writer);
                        }
                        writer.RenderBeginTag(HtmlTextWriterTag.A);
                        writer.Write(str);
                        writer.RenderEndTag();
                    }
                }
                if (this.PagingButtonLayoutType != PagingButtonLayoutType.None)
                {
                    writer.RenderEndTag();
                }
            }
        }

        private void CreateNumericButton(HtmlTextWriter writer, int index)
        {
            bool flag = index == this.CurrentPageIndex;
            if ((!flag && (this.PagingButtonLayoutType !=PagingButtonLayoutType.None)) || (flag && (this.PagingButtonLayoutType == PagingButtonLayoutType.UnorderedList)))
            {
                this.AddPagingButtonLayoutTag(writer);
            }
            if ((this.PagingButtonType ==PagingButtonType.Image) && (this.NumericButtonType == PagingButtonType.Image))
            {
                this.writeSpacingStyle(writer);
                if (!flag)
                {
                    if (this.Enabled)
                    {
                        writer.AddAttribute(HtmlTextWriterAttribute.Href, this.GetHrefString(index));
                    }
                    this.AddToolTip(writer, index);
                    this.AddHyperlinkTarget(writer);
                    writer.RenderBeginTag(HtmlTextWriterTag.A);
                    this.CreateNumericImages(writer, index, false);
                    writer.RenderEndTag();
                }
                else
                {
                    if (!string.IsNullOrEmpty(this.CurrentPageButtonClass))
                    {
                        writer.AddAttribute(HtmlTextWriterAttribute.Class, this.CurrentPageButtonClass);
                    }
                    if (!string.IsNullOrEmpty(this.CurrentPageButtonStyle))
                    {
                        writer.AddAttribute(HtmlTextWriterAttribute.Style, this.CurrentPageButtonStyle);
                    }
                    writer.RenderBeginTag(HtmlTextWriterTag.Span);
                    this.CreateNumericImages(writer, index, true);
                    writer.RenderEndTag();
                }
            }
            else
            {
                this.writeSpacingStyle(writer);
                if (flag)
                {
                    if (string.IsNullOrEmpty(this.CurrentPageButtonClass) && string.IsNullOrEmpty(this.CurrentPageButtonStyle))
                    {
                        writer.AddStyleAttribute(HtmlTextWriterStyle.FontWeight, "Bold");
                        writer.AddStyleAttribute(HtmlTextWriterStyle.Color, "red");
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(this.CurrentPageButtonClass))
                        {
                            writer.AddAttribute(HtmlTextWriterAttribute.Class, this.CurrentPageButtonClass);
                        }
                        if (!string.IsNullOrEmpty(this.CurrentPageButtonStyle))
                        {
                            writer.AddAttribute(HtmlTextWriterAttribute.Style, this.CurrentPageButtonStyle);
                        }
                    }
                    writer.RenderBeginTag(HtmlTextWriterTag.Span);
                    if (!string.IsNullOrEmpty(this.CurrentPageButtonTextFormatString))
                    {
                        writer.Write(string.Format(this.CurrentPageButtonTextFormatString, index));
                    }
                    else
                    {
                        writer.Write(index);
                    }
                    writer.RenderEndTag();
                }
                else
                {
                    if (this.Enabled)
                    {
                        writer.AddAttribute(HtmlTextWriterAttribute.Href, this.GetHrefString(index));
                    }
                    this.WriteCssClass(writer);
                    this.AddToolTip(writer, index);
                    this.AddHyperlinkTarget(writer);
                    writer.RenderBeginTag(HtmlTextWriterTag.A);
                    if (!string.IsNullOrEmpty(this.NumericButtonTextFormatString))
                    {
                        writer.Write(string.Format(this.NumericButtonTextFormatString, index));
                    }
                    else
                    {
                        writer.Write(index);
                    }
                    writer.RenderEndTag();
                }
            }
            if ((!flag && (this.PagingButtonLayoutType != PagingButtonLayoutType.None)) || (flag && (this.PagingButtonLayoutType == PagingButtonLayoutType.UnorderedList)))
            {
                writer.RenderEndTag();
            }
        }

        private void CreateNumericImages(HtmlTextWriter writer, int index, bool isCurrent)
        {
            this.AddPagingButtonLayoutTag(writer);
            string str = index.ToString();
            for (int i = 0; i < str.Length; i++)
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Src, string.Concat(new object[] { this.ImagePath, str[i], isCurrent ? this.CpiButtonImageNameExtension : this.ButtonImageNameExtension, this.ButtonImageExtension }));
                if (this.ButtonImageAlign != ImageAlign.NotSet)
                {
                    writer.AddAttribute(HtmlTextWriterAttribute.Align, this.ButtonImageAlign.ToString());
                }
                writer.AddAttribute(HtmlTextWriterAttribute.Border, "0");
                writer.RenderBeginTag(HtmlTextWriterTag.Img);
                writer.RenderEndTag();
            }
            if (this.PagingButtonLayoutType != PagingButtonLayoutType.None)
            {
                writer.RenderEndTag();
            }
        }

        private string GetCustomInfoHTML(string origText)
        {
            if (string.IsNullOrEmpty(origText) || (origText.IndexOf('%') < 0))
            {
                return origText;
            }
            string[] array = new string[] { "recordcount", "pagecount", "currentpageindex", "startrecordindex", "endrecordindex", "pagesize", "pagesremain", "recordsremain" };
            StringBuilder builder = new StringBuilder(origText);
            Regex regex = new Regex(@"(?<ph>%(?<pname>\w{8,})%)", RegexOptions.Compiled | RegexOptions.IgnoreCase);
            foreach (Match match in regex.Matches(origText))
            {
                string str = match.Groups["pname"].Value.ToLower();
                if (Array.IndexOf<string>(array, str) >= 0)
                {
                    string newValue = null;
                    switch (str)
                    {
                        case "recordcount":
                            newValue = this.RecordCount.ToString();
                            break;

                        case "pagecount":
                            newValue = this.PageCount.ToString();
                            break;

                        case "currentpageindex":
                            newValue = this.CurrentPageIndex.ToString();
                            break;

                        case "startrecordindex":
                            newValue = this.StartRecordIndex.ToString();
                            break;

                        case "endrecordindex":
                            newValue = this.EndRecordIndex.ToString();
                            break;

                        case "pagesize":
                            newValue = this.PageSize.ToString();
                            break;

                        case "pagesremain":
                            newValue = this.PagesRemain.ToString();
                            break;

                        case "recordsremain":
                            newValue = this.RecordsRemain.ToString();
                            break;
                    }
                    if (newValue != null)
                    {
                        builder.Replace(match.Groups["ph"].Value, newValue);
                    }
                }
            }
            return builder.ToString();
        }
		private string GetHrefFormatStr() {
			var retVal =new StringBuilder();
			if (!this.UrlPaging) {
				retVal.Append(this.Page.ClientScript.GetPostBackClientHyperlink(this, "%p%"));
				return retVal.ToString().ToLower().Replace("javascript:","");
			};

			if (!this.EnableUrlRewriting) {
				if (this.Page.Request.QueryString.Count == 0 || (this.Page.Request.QueryString.Count == 1 && string.IsNullOrEmpty(this.Page.Request.QueryString[0])))
				{
					retVal.AppendFormat("{0}{1}?{2}=%p%",
                        SystemX.Web.Utils.AbsoluteWebRoot.ToString(),
						currentUrl.Substring(0, currentUrl.IndexOf(Path.GetFileName(currentUrl))), 
						this.UrlPageIndexName);
				}
				else {
					currentUrl=currentUrl.EndsWith("&")?currentUrl.Substring(0,currentUrl.Length-1):currentUrl;
					retVal.AppendFormat("{0}{1}?{2}=%p%",
                        SystemX.Web.Utils.AbsoluteWebRoot,
						currentUrl,
						this.UrlPageIndexName
						);
				};
				return retVal.ToString();
			}

			//TODO:
			return retVal.ToString();
		}
        private string GetHrefString(int pageIndex)
        {
            if (!this.UrlPaging)
            {
                return this.Page.ClientScript.GetPostBackClientHyperlink(this, pageIndex.ToString());
            }
            int num = pageIndex;
            string str = "pi";
            if (this.ReverseUrlPageIndex)
            {
                str = "(" + this.PageCount + "-pi+1)";
                num = (pageIndex == -1) ? -1 : ((this.PageCount - pageIndex) + 1);
            }
            if (!this.EnableUrlRewriting)
            {
                return this.BuildUrlString(this.UrlPageIndexName, (num == -1) ? ("\"+" + str + "+\"") : num.ToString());
            }
            MatchCollection matchs = new Regex("(?<p>%(?<m>[^%]+)%)", RegexOptions.Compiled | RegexOptions.IgnoreCase).Matches(this.UrlRewritePattern);
            NameValueCollection values = ConvertQueryStringToCollection(this.queryString);
            string urlRewritePattern = this.UrlRewritePattern;
            foreach (Match match in matchs)
            {
                string newValue = values[match.Groups["m"].Value];
                urlRewritePattern = urlRewritePattern.Replace(match.Groups["p"].Value, newValue);
            }
            return base.ResolveUrl(string.Format(urlRewritePattern, (num == -1) ? ("\"+" + str + "+\"") : num.ToString()));
        }

        public virtual void GoToPage(int pageIndex)
        {
            this.OnPageChanging(new PageChangingEventArgs(pageIndex));
        }

        private void listPageIndices(HtmlTextWriter writer, int startIndex, int endIndex)
        {
            for (int i = startIndex; i <= endIndex; i++)
            {
                writer.Write("<option value=\"");
                writer.Write(i);
                writer.Write("\"");
                if (i == this.CurrentPageIndex)
                {
                    writer.Write(" selected=\"true\"");
                }
                writer.Write(">");
                writer.Write(i);
                writer.Write("</option>");
            }
		}
		private void RenderCustomInfoSection(HtmlTextWriter writer)
		{
			if (this.Height != Unit.Empty)
			{
				writer.AddStyleAttribute(HtmlTextWriterStyle.Height, this.Height.ToString());
			}
			string str = this.CustomTipSectionWidth.ToString();
			if ((this.CustomTipClass != null) && (this.CustomTipClass.Trim().Length > 0))
			{
				writer.AddAttribute(HtmlTextWriterAttribute.Class, this.CustomTipClass);
			}
			if ((this.CustomTipStyle != null) && (this.CustomTipStyle.Trim().Length > 0))
			{
				writer.AddAttribute(HtmlTextWriterAttribute.Style, this.CustomTipStyle);
			}
			writer.AddStyleAttribute(HtmlTextWriterStyle.Width, str);
			if (this.CustomTipTextAlign != HorizontalAlign.NotSet)
			{
				writer.AddAttribute(HtmlTextWriterAttribute.Align, this.CustomTipTextAlign.ToString().ToLower());
			}
			if (this.LayoutType == LayoutType.Div)
			{
				writer.AddStyleAttribute("float", "left");
				writer.RenderBeginTag(HtmlTextWriterTag.Div);
			}
			else
			{
				writer.AddAttribute(HtmlTextWriterAttribute.Valign, "bottom");
				writer.AddAttribute(HtmlTextWriterAttribute.Nowrap, "true");
				writer.RenderBeginTag(HtmlTextWriterTag.Td);
			}
			writer.Write(this.GetCustomInfoHTML(this.CustomTipHTML));
			writer.RenderEndTag();
		}
		private void RenderNavigationSection(HtmlTextWriter writer)
		{
			if (this.CustomTipSectionWidth.Type == UnitType.Percentage)
			{
				writer.AddStyleAttribute(HtmlTextWriterStyle.Width, Unit.Percentage(100.0 - this.CustomTipSectionWidth.Value).ToString());
			}
			if (this.HorizontalAlign != HorizontalAlign.NotSet)
			{
				writer.AddAttribute(HtmlTextWriterAttribute.Align, this.HorizontalAlign.ToString().ToLower());
			}
			if (!string.IsNullOrEmpty(this.CssClass))
			{
				writer.AddAttribute(HtmlTextWriterAttribute.Class, this.CssClass);
			}
			if (this.LayoutType == LayoutType.Div)
			{
				writer.AddStyleAttribute("float", "left");
				writer.RenderBeginTag(HtmlTextWriterTag.Div);
			}
			else
			{
				writer.AddAttribute(HtmlTextWriterAttribute.Valign, "bottom");
				writer.AddAttribute(HtmlTextWriterAttribute.Nowrap, "true");
				writer.RenderBeginTag(HtmlTextWriterTag.Td);
			}
			this.RenderPagingElements(writer);
			writer.RenderEndTag();
		}

		private void RenderPagingElements(HtmlTextWriter writer)
		{
			int pageIndex = ((this.CurrentPageIndex - 1) / this.NumericButtonCount) * this.NumericButtonCount;
			if ((this.PageCount > this.NumericButtonCount) && (this.CurrentPageButtonPosition != PagingButtonPosition.Fixed))
			{
				switch (this.CurrentPageButtonPosition)
				{
					case PagingButtonPosition.Beginning:
						pageIndex = this.CurrentPageIndex - 1;
						if ((pageIndex + this.NumericButtonCount) > this.PageCount)
						{
							pageIndex = this.PageCount - this.NumericButtonCount;
						}
						break;

					case PagingButtonPosition.End:
						if (this.CurrentPageIndex > this.NumericButtonCount)
						{
							pageIndex = this.CurrentPageIndex - this.NumericButtonCount;
						}
						break;

					case PagingButtonPosition.Center:
						{
							int num2 = this.CurrentPageIndex - ((int)Math.Ceiling((double)(((double)this.NumericButtonCount) / 2.0)));
							if (num2 > 0)
							{
								pageIndex = num2;
								if (pageIndex > (this.PageCount - this.NumericButtonCount))
								{
									pageIndex = this.PageCount - this.NumericButtonCount;
								}
							}
							break;
						}
				}
			}
			int num3 = ((pageIndex + this.NumericButtonCount) > this.PageCount) ? this.PageCount : (pageIndex + this.NumericButtonCount);
			if (this.PagingButtonLayoutType == PagingButtonLayoutType.UnorderedList)
			{
				writer.RenderBeginTag(HtmlTextWriterTag.Ul);
			}
			this.CreateNavigationButton(writer, "first");
			this.CreateNavigationButton(writer, "prev");
			if (this.ShowPageIndex)
			{
				if (pageIndex > 0)
				{
					this.CreateMoreButton(writer, pageIndex);
				}
				for (int i = pageIndex + 1; i <= num3; i++)
				{
					this.CreateNumericButton(writer, i);
				}
				if ((this.PageCount > this.NumericButtonCount) && (num3 < this.PageCount))
				{
					this.CreateMoreButton(writer, num3 + 1);
				}
			}
			this.CreateNavigationButton(writer, "next");
			this.CreateNavigationButton(writer, "last");
			if (this.PagingButtonLayoutType == PagingButtonLayoutType.UnorderedList)
			{
				writer.RenderEndTag();
			}
			if ((this.ShowPageIndexBox == ShowPageIndexBox.Always) || ((this.ShowPageIndexBox == ShowPageIndexBox.Auto) && (this.PageCount >= this.ShowBoxThreshold)))
			{
				string str = String.Format("{0}_input", this.UniqueID);
				writer.Write("&nbsp;&nbsp;");
				if (!string.IsNullOrEmpty(this.TextBeforePageIndexBox))
				{
					writer.Write(this.TextBeforePageIndexBox);
				}
				if (this.PageIndexBoxType == PageIndexBoxType.TextBox)
				{
					writer.AddAttribute(HtmlTextWriterAttribute.Type, "text");
					writer.AddStyleAttribute(HtmlTextWriterStyle.Width, "30px");
					writer.AddAttribute(HtmlTextWriterAttribute.Value, this.CurrentPageIndex.ToString());
					if (!string.IsNullOrEmpty(this.PageIndexBoxStyle))
					{
						writer.AddAttribute(HtmlTextWriterAttribute.Style, this.PageIndexBoxStyle);
					}
					if (!string.IsNullOrEmpty(this.PageIndexBoxClass))
					{
						writer.AddAttribute(HtmlTextWriterAttribute.Class, this.PageIndexBoxClass);
					}
					if (!this.Enabled || ((this.PageCount <= 1) && this.AlwaysShow))
					{
						writer.AddAttribute(HtmlTextWriterAttribute.Disabled, "disabled");
					}
					writer.AddAttribute(HtmlTextWriterAttribute.Name, str);
					writer.AddAttribute(HtmlTextWriterAttribute.Id, str);
					string str2 = string.Concat(new object[] { "XPagerCheckInput('", str, "',", this.PageCount, ")" });
					string str3 = String.Format("XPagerKeydown(event,'{0}_btn');", this.UniqueID);
					string str4 = "if(" + str2 + "){XPagerTo(document.getElementById('" + str + "'));};return false;";
					writer.AddAttribute("onkeydown", str3);
					writer.RenderBeginTag(HtmlTextWriterTag.Input);
					writer.RenderEndTag();
					if (!string.IsNullOrEmpty(this.TextAfterPageIndexBox))
					{
						writer.Write(this.TextAfterPageIndexBox);
					}
					if (!string.IsNullOrEmpty(this.SubmitButtonImageUrl))
					{
						writer.AddAttribute(HtmlTextWriterAttribute.Type, "image");
						writer.AddAttribute(HtmlTextWriterAttribute.Src, this.SubmitButtonImageUrl);
					}
					else
					{
						writer.AddAttribute(HtmlTextWriterAttribute.Type, this.UrlPaging ? "button" : "submit");
						writer.AddAttribute(HtmlTextWriterAttribute.Value, this.SubmitButtonText);
					}
					writer.AddAttribute(HtmlTextWriterAttribute.Name, this.UniqueID);
					writer.AddAttribute(HtmlTextWriterAttribute.Id, this.UniqueID + "_btn");
					if (!string.IsNullOrEmpty(this.SubmitButtonClass))
					{
						writer.AddAttribute(HtmlTextWriterAttribute.Class, this.SubmitButtonClass);
					}
					if (!string.IsNullOrEmpty(this.SubmitButtonStyle))
					{
						writer.AddAttribute(HtmlTextWriterAttribute.Style, this.SubmitButtonStyle);
					}
					if (!this.Enabled || ((this.PageCount <= 1) && this.AlwaysShow))
					{
						writer.AddAttribute(HtmlTextWriterAttribute.Disabled, "disabled");
					}
					writer.AddAttribute(HtmlTextWriterAttribute.Onclick, this.UrlPaging ? str4 : ("if(" + str2 + "){" + this.Page.ClientScript.GetPostBackEventReference(this, null) + "} else{return false;}"));
					writer.RenderBeginTag(HtmlTextWriterTag.Input);
					writer.RenderEndTag();
				}
				else
				{
					writer.AddAttribute(HtmlTextWriterAttribute.Name, str);
					writer.AddAttribute(HtmlTextWriterAttribute.Id, str);
					writer.AddAttribute(HtmlTextWriterAttribute.Onchange, this.UrlPaging ? "XPagerTo(this)" : this.Page.ClientScript.GetPostBackEventReference(this, null));
					writer.RenderBeginTag(HtmlTextWriterTag.Select);
					if (this.PageCount > 80)
					{
						if (this.CurrentPageIndex <= 15)
						{
							this.listPageIndices(writer, 1, 15);
							addMoreListItem(writer, 0x10);
							this.listPageIndices(writer, this.PageCount - 4, this.PageCount);
						}
						else if (this.CurrentPageIndex >= (this.PageCount - 14))
						{
							this.listPageIndices(writer, 1, 5);
							addMoreListItem(writer, this.PageCount - 15);
							this.listPageIndices(writer, this.PageCount - 14, this.PageCount);
						}
						else
						{
							this.listPageIndices(writer, 1, 5);
							addMoreListItem(writer, this.CurrentPageIndex - 6);
							this.listPageIndices(writer, this.CurrentPageIndex - 5, this.CurrentPageIndex + 5);
							addMoreListItem(writer, this.CurrentPageIndex + 6);
							this.listPageIndices(writer, this.PageCount - 4, this.PageCount);
						}
					}
					else
					{
						this.listPageIndices(writer, 1, this.PageCount);
					}
					writer.RenderEndTag();
					if (!string.IsNullOrEmpty(this.TextAfterPageIndexBox))
					{
						writer.Write(this.TextAfterPageIndexBox);
					}
				}
			}
		}

		private void WriteCssClass(HtmlTextWriter writer)
		{
			if ((this.cssClassName != null) && (this.cssClassName.Trim().Length > 0))
			{
				writer.AddAttribute(HtmlTextWriterAttribute.Class, this.cssClassName);
			}
		}

		private void writeSpacingStyle(HtmlTextWriter writer)
		{
			if (this.PagingButtonSpacing.Value != 0.0)
			{
				writer.AddStyleAttribute(HtmlTextWriterStyle.MarginRight, this.PagingButtonSpacing.ToString());
			}
		}
		#endregion

		#region methods
		public virtual bool LoadPostData(string pkey, NameValueCollection pcol)
        {
			string s = pcol[String.Format("{0}_input", UniqueID)];
            if ((s != null) && (s.Trim().Length > 0))
            {
                try
                {
                    int num = int.Parse(s);
                    if ((num > 0) && (num <= this.PageCount))
                    {
                        this.inputPageIndex = s;
                        this.Page.RegisterRequiresRaiseEvent(this);
                    }
                }
                catch
                {
                }
            }
            return false;
        }

        protected virtual void OnPageChanged(EventArgs e)
        {
            EventHandler handler = (EventHandler) base.Events[EventPageChanged];
            if (handler != null)
            {
                handler(this, e);
            }
        }

        protected virtual void OnPageChanging(PageChangingEventArgs e)
        {
            PageChangingEventHandler handler = (PageChangingEventHandler) base.Events[EventPageChanging];
            if (handler != null)
            {
                handler(this, e);
                if (!e.Cancel || this.UrlPaging)
                {
                    this.CurrentPageIndex = e.NewPageIndex;
                    this.OnPageChanged(EventArgs.Empty);
                }
            }
            else
            {
                this.CurrentPageIndex = e.NewPageIndex;
                this.OnPageChanged(EventArgs.Empty);
            }
		}
		//IPostBackEventHandler
		public void RaisePostBackEvent(string args)
		{
			int currentPageIndex = this.CurrentPageIndex;
			try
			{
				if (string.IsNullOrEmpty(args))
				{
					args = this.inputPageIndex;
				}
				currentPageIndex = int.Parse(args);
			}
			catch
			{
			}
			PageChangingEventArgs e = new PageChangingEventArgs(currentPageIndex);
			if (this.cloneFrom != null)
			{
				this.cloneFrom.OnPageChanging(e);
			}
			else
			{
				this.OnPageChanging(e);
			}
		}

		public virtual void RaisePostDataChangedEvent()
		{
		}
		#endregion

		#region properties
		[Browsable(true), Themeable(true), Category("Behavior"), DefaultValue(false), XDescription("desc_AlwaysShow")]
        public bool AlwaysShow
        {
            get
            {
                object obj2 = this.ViewState["AlwaysShow"];
                if (obj2 != null)
                {
                    return (bool) obj2;
                }
                return ((this.cloneFrom != null) && this.cloneFrom.AlwaysShow);
            }
            set
            {
                this.ViewState["AlwaysShow"] = value;
            }
        }

        [Category("Appearance"), Browsable(true), XDescription("desc_ButtonImageAlign"), DefaultValue(0)]
        public ImageAlign ButtonImageAlign
        {
            get
            {
                if (this.cloneFrom != null)
                {
                    return this.cloneFrom.ButtonImageAlign;
                }
                object obj2 = this.ViewState["ButtonImageAlign"];
                if (obj2 != null)
                {
                    return (ImageAlign) obj2;
                }
                return ImageAlign.NotSet;
            }
            set
            {
                if ((value != ImageAlign.Right) && (value != ImageAlign.Left))
                {
                    this.ViewState["ButtonImageAlign"] = value;
                }
            }
        }

        [Themeable(true), DefaultValue(".gif"), XDescription("desc_ButtonImageExtension"), Browsable(true), Category("Appearance")]
        public string ButtonImageExtension
        {
            get
            {
                if (this.cloneFrom != null)
                {
                    return this.cloneFrom.ButtonImageExtension;
                }
                object obj2 = this.ViewState["ButtonImageExtension"];
                if (obj2 != null)
                {
                    return (string) obj2;
                }
                return ".gif";
            }
            set
            {
                string str = value.Trim();
                this.ViewState["ButtonImageExtension"] = str.StartsWith(".") ? str : ("." + str);
            }
        }

        [XDescription("desc_ButtonImageNameExtension"), Category("Appearance"), Browsable(true), Themeable(true), DefaultValue((string) null)]
        public string ButtonImageNameExtension
        {
            get
            {
                if (this.cloneFrom != null)
                {
                    return this.cloneFrom.ButtonImageNameExtension;
                }
                object obj2 = this.ViewState["ButtonImageNameExtension"];
                if (obj2 != null)
                {
                    return (string) obj2;
                }
                return null;
            }
            set
            {
                this.ViewState["ButtonImageNameExtension"] = value;
            }
        }

        [XDescription("desc_CenterCurrentPageButton"), Themeable(false), XCategory("Behavior"), Obsolete("use CurrentPageButtonPosition instead"), DefaultValue(false), Browsable(false)]
        public bool CenterCurrentPageButton
        {
            get
            {
                return (this.CurrentPageButtonPosition == PagingButtonPosition.Center);
            }
            set
            {
                this.CurrentPageButtonPosition = PagingButtonPosition.Center;
            }
        }

        [Browsable(true), DefaultValue(false), Themeable(false), TypeConverter(typeof(XPagerIDConverter)), Category("Behavior"), XDescription("desc_CloneFrom")]
        public string CloneFrom
        {
            get
            {
                return (string) this.ViewState["CloneFrom"];
            }
            set
            {
                if ((value != null) && (string.Empty == value.Trim()))
                {
                    throw new ArgumentNullException("CloneFrom", "The Value of property CloneFrom can not be empty string!");
                }
                if (this.ID.Equals(value, StringComparison.OrdinalIgnoreCase))
                {
                    throw new ArgumentException("The property value of CloneFrom can not be set to control itself!", "CloneFrom");
                }
                this.ViewState["CloneFrom"] = value;
            }
        }

        [XDescription("desc_CpiButtonImageNameExtension"), Browsable(true), Category("Appearance"), Themeable(true), DefaultValue((string) null)]
        public string CpiButtonImageNameExtension
        {
            get
            {
                if (this.cloneFrom != null)
                {
                    return this.cloneFrom.CpiButtonImageNameExtension;
                }
                object obj2 = this.ViewState["CpiButtonImageNameExtension"];
                if (obj2 != null)
                {
                    return (string) obj2;
                }
                return this.ButtonImageNameExtension;
            }
            set
            {
                this.ViewState["CpiButtonImageNameExtension"] = value;
            }
        }

        [DefaultValue((string) null), Browsable(true), XDescription("desc_CssClass"), Category("Appearance")]
        public override string CssClass
        {
            get
            {
                return base.CssClass;
            }
            set
            {
                base.CssClass = value;
                this.cssClassName = value;
            }
        }

        [Browsable(true), Category("Appearance"), XDescription("desc_CurrentPageButtonClass"), DefaultValue((string) null)]
        public string CurrentPageButtonClass
        {
            get
            {
                if (this.cloneFrom != null)
                {
                    return this.cloneFrom.CurrentPageButtonClass;
                }
                object obj2 = this.ViewState["CPBClass"];
                if (obj2 != null)
                {
                    return (string) obj2;
                }
                return null;
            }
            set
            {
                this.ViewState["CPBClass"] = value;
            }
        }

        [XDescription("desc_CurrentPageButtonPosition"), XCategory("cat_Navigation"), Browsable(true), Themeable(true), DefaultValue(3)]
        public PagingButtonPosition CurrentPageButtonPosition
        {
            get
            {
                if (this.cloneFrom != null)
                {
                    return this.cloneFrom.CurrentPageButtonPosition;
                }
                object obj2 = this.ViewState["CurrentPageButtonPosition"];
                if (obj2 != null)
                {
                    return (PagingButtonPosition) obj2;
                }
                return PagingButtonPosition.Fixed;
            }
            set
            {
                this.ViewState["CurrentPageButtonPosition"] = value;
            }
        }

        [Category("Appearance"), Browsable(true), XDescription("desc_CurrentPageButtonStyle"), DefaultValue((string) null)]
        public string CurrentPageButtonStyle
        {
            get
            {
                if (this.cloneFrom != null)
                {
                    return this.cloneFrom.CurrentPageButtonStyle;
                }
                object obj2 = this.ViewState["CPBStyle"];
                if (obj2 != null)
                {
                    return (string) obj2;
                }
                return null;
            }
            set
            {
                this.ViewState["CPBStyle"] = value;
            }
        }

        [XCategory("cat_Navigation"), DefaultValue(""), XDescription("desc_CPBTextFormatString"), Browsable(true), Themeable(true)]
        public string CurrentPageButtonTextFormatString
        {
            get
            {
                if (this.cloneFrom != null)
                {
                    return this.cloneFrom.CurrentPageButtonTextFormatString;
                }
                object obj2 = this.ViewState["CurrentPageButtonTextFormatString"];
                if (obj2 != null)
                {
                    return (string) obj2;
                }
                return this.NumericButtonTextFormatString;
            }
            set
            {
                this.ViewState["CurrentPageButtonTextFormatString"] = value;
            }
        }

        [Browsable(true), XCategory("cat_Paging"), XDescription("desc_CurrentPageIndex"), DefaultValue(1)]
        public int CurrentPageIndex
        {
            get
            {
                if (this.cloneFrom != null)
                {
                    return this.cloneFrom.CurrentPageIndex;
                }
                object obj2 = this.ViewState["CurrentPageIndex"];
                int num = (obj2 == null) ? 1 : ((int) obj2);
                if ((num > this.PageCount) && (this.PageCount > 0))
                {
                    return this.PageCount;
                }
                if (num < 1)
                {
                    return 1;
                }
                return num;
            }
            set
            {
                int pageCount = value;
                if (pageCount < 1)
                {
                    pageCount = 1;
                }
                else if (pageCount > this.PageCount)
                {
                    pageCount = this.PageCount;
                }
                this.ViewState["CurrentPageIndex"] = pageCount;
            }
        }

		[DefaultValue((string)null), XDescription("desc_CustomTipClass"), Category("Appearance"), Browsable(true)]
        public string CustomTipClass
        {
            get
            {
                if (this.cloneFrom != null)
                {
                    return this.cloneFrom.CustomTipClass;
                }
				object obj2 = this.ViewState["CustomTipClass"];
                if (obj2 != null)
                {
                    return (string) obj2;
                }
                return this.CssClass;
            }
            set
            {
				this.ViewState["CustomTipClass"] = value;
            }
        }

		[Themeable(true), Browsable(true), XDescription("desc_CustomTipHTML"), Category("Appearance"), DefaultValue("Page %CurrentPageIndex% of %PageCount%")]
        public string CustomTipHTML
        {
            get
            {
                if (this.cloneFrom != null)
                {
                    return this.cloneFrom.CustomTipHTML;
                }
				object obj2 = this.ViewState["CustomTipHTML"];
                if (obj2 != null)
                {
                    return (string) obj2;
                }
                return "Page %CurrentPageIndex% of %PageCount%";
            }
            set
            {
				this.ViewState["CustomTipHTML"] = value;
            }
        }

        [XDescription("desc_CustomTipSectionWidth"), Category("Appearance"), Browsable(true), DefaultValue(typeof(Unit), "40%")]
        public Unit CustomTipSectionWidth
        {
            get
            {
                if (this.cloneFrom != null)
                {
					return this.cloneFrom.CustomTipSectionWidth;
                }
				object obj2 = this.ViewState["CustomTipSectionWidth"];
                if (obj2 != null)
                {
                    return (Unit) obj2;
                }
                return Unit.Percentage(40.0);
            }
            set
            {
				this.ViewState["CustomTipSectionWidth"] = value;
            }
        }

		[Browsable(true), XDescription("desc_CustomTipStyle"), Category("Appearance"), DefaultValue((string)null)]
        public string CustomTipStyle
        {
            get
            {
                if (this.cloneFrom != null)
                {
                    return this.cloneFrom.CustomTipStyle;
                }
				object obj2 = this.ViewState["CustomTipStyle"];
                if (obj2 != null)
                {
                    return (string) obj2;
                }
                return base.Style.Value;
            }
            set
            {
				this.ViewState["CustomTipStyle"] = value;
            }
        }

		[XDescription("desc_CustomTipTextAlign"), DefaultValue(0), Browsable(true), Category("Appearance")]
        public HorizontalAlign CustomTipTextAlign
        {
            get
            {
                if (this.cloneFrom != null)
                {
                    return this.cloneFrom.CustomTipTextAlign;
                }
				object obj2 = this.ViewState["CustomTipTextAlign"];
                if (obj2 != null)
                {
                    return (HorizontalAlign) obj2;
                }
                return HorizontalAlign.NotSet;
            }
            set
            {
				this.ViewState["CustomTipTextAlign"] = value;
            }
        }

        [Themeable(true), Browsable(true), XDescription("desc_DisabledButtonImageNameExtension"), DefaultValue((string) null), Category("Appearance")]
        public string DisabledButtonImageNameExtension
        {
            get
            {
                if (this.cloneFrom != null)
                {
                    return this.cloneFrom.DisabledButtonImageNameExtension;
                }
                object obj2 = this.ViewState["DisabledButtonImageNameExtension"];
                if (obj2 != null)
                {
                    return (string) obj2;
                }
                return this.ButtonImageNameExtension;
            }
            set
            {
                this.ViewState["DisabledButtonImageNameExtension"] = value;
            }
        }

        public override bool EnableTheming
        {
            get
            {
                if (this.cloneFrom != null)
                {
                    return this.cloneFrom.EnableTheming;
                }
                return base.EnableTheming;
            }
            set
            {
                base.EnableTheming = value;
            }
        }

        [Browsable(true), DefaultValue(false), Themeable(true), Category("Behavior"), XDescription("desc_EnableUrlWriting")]
        public bool EnableUrlRewriting
        {
            get
            {
                object obj2 = this.ViewState["UrlRewriting"];
                if (obj2 != null)
                {
                    return (bool) obj2;
                }
                return ((this.cloneFrom != null) && this.cloneFrom.EnableUrlRewriting);
            }
            set
            {
                this.ViewState["UrlRewriting"] = value;
                if (value)
                {
                    this.UrlPaging = true;
                }
            }
        }

        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Browsable(false)]
        public int EndRecordIndex
        {
            get
            {
                return (this.RecordCount - this.RecordsRemain);
            }
        }

        [Themeable(true), DefaultValue("&lt;&lt;"), XCategory("cat_Navigation"), Browsable(true), XDescription("desc_FirstPageText")]
        public string FirstPageText
        {
            get
            {
                if (this.cloneFrom != null)
                {
                    return this.cloneFrom.FirstPageText;
                }
                object obj2 = this.ViewState["FirstPageText"];
                if (obj2 != null)
                {
                    return (string) obj2;
                }
                return "&lt;&lt;";
            }
            set
            {
                this.ViewState["FirstPageText"] = value;
            }
        }

        [Browsable(true), XDescription("desc_ImagePath"), DefaultValue((string) null), Category("Appearance")]
        public string ImagePath
        {
            get
            {
                if (this.cloneFrom != null)
                {
                    return this.cloneFrom.ImagePath;
                }
                string relativeUrl = (string) this.ViewState["ImagePath"];
                if (relativeUrl != null)
                {
                    relativeUrl = base.ResolveUrl(relativeUrl);
                }
                return relativeUrl;
            }
            set
            {
                string str = value.Trim().Replace(@"\", "/");
                this.ViewState["ImagePath"] = str.EndsWith("/") ? str : (str + "/");
            }
        }

        [XDefaultValue("def_InvalidPIErrorMsg"), Browsable(true), XDescription("desc_InvalidPIErrorMsg"), Category("Data"), Themeable(true)]
        public string InvalidPageIndexErrorMessage
        {
            get
            {
                object obj2 = this.ViewState["InvalidPIErrorMsg"];
                if (obj2 != null)
                {
                    return (string) obj2;
                }
                if (this.cloneFrom != null)
                {
                    return this.cloneFrom.InvalidPageIndexErrorMessage;
                }
                return ResReader.GetString("def_InvalidPIErrorMsg");
            }
            set
            {
                this.ViewState["InvalidPIErrorMsg"] = value;
            }
        }

        [Browsable(true), DefaultValue("&gt;&gt;"), XDescription("desc_LastPageText"), Themeable(true), XCategory("cat_Navigation")]
        public string LastPageText
        {
            get
            {
                if (this.cloneFrom != null)
                {
                    return this.cloneFrom.LastPageText;
                }
                object obj2 = this.ViewState["LastPageText"];
                if (obj2 != null)
                {
                    return (string) obj2;
                }
                return "&gt;&gt;";
            }
            set
            {
                this.ViewState["LastPageText"] = value;
            }
        }

        [Themeable(true), XDefaultValue("Div"), XDescription("desc_LayoutType"), Category("Appearance"), Browsable(true)]
        public LayoutType LayoutType
        {
            get
            {
                if (this.cloneFrom != null)
                {
                    return this.cloneFrom.LayoutType;
                }
                object obj2 = this.ViewState["LayoutType"];
                if (obj2 != null)
                {
                    return (LayoutType) obj2;
                }
                return LayoutType.Div;
            }
            set
            {
                this.ViewState["LayoutType"] = value;
            }
        }

        [Themeable(true), DefaultValue(0), XDescription("desc_MoreButtonType"), Browsable(true), XCategory("cat_Navigation")]
        public PagingButtonType MoreButtonType
        {
            get
            {
                if (this.cloneFrom != null)
                {
                    return this.cloneFrom.MoreButtonType;
                }
                object obj2 = this.ViewState["MoreButtonType"];
                if (obj2 != null)
                {
                    return (PagingButtonType) obj2;
                }
                return this.PagingButtonType;
            }
            set
            {
                this.ViewState["MoreButtonType"] = value;
            }
        }

        [XDescription("desc_NavigationButtonType"), Browsable(true), Themeable(true), XCategory("cat_Navigation"), DefaultValue(0)]
        public PagingButtonType NavigationButtonType
        {
            get
            {
                if (this.cloneFrom != null)
                {
                    return this.cloneFrom.NavigationButtonType;
                }
                object obj2 = this.ViewState["NavigationButtonType"];
                if (obj2 != null)
                {
                    return (PagingButtonType) obj2;
                }
                return this.PagingButtonType;
            }
            set
            {
                this.ViewState["NavigationButtonType"] = value;
            }
        }

        [XDescription("desc_NavigationToolTipTextFormatString"), XCategory("cat_Navigation"), XDefaultValue("def_NavigationToolTipTextFormatString"), Browsable(true), Themeable(true)]
        public string NavigationToolTipTextFormatString
        {
            get
            {
                if (this.cloneFrom != null)
                {
                    return this.cloneFrom.NavigationToolTipTextFormatString;
                }
                object obj2 = this.ViewState["NvToolTipFormatString"];
                if (obj2 != null)
                {
                    return (string) obj2;
                }
                if (this.ShowNavigationToolTip)
                {
                    return ResReader.GetString("def_NavigationToolTipTextFormatString");
                }
                return null;
            }
            set
            {
                string str = value;
                if ((str.Trim().Length < 1) && (str.IndexOf("{0}") < 0))
                {
                    str = "{0}";
                }
                this.ViewState["NvToolTipFormatString"] = str;
            }
        }

        [XDescription("desc_NextPageText"), DefaultValue("&gt;"), XCategory("cat_Navigation"), Browsable(true), Themeable(true)]
        public string NextPageText
        {
            get
            {
                if (this.cloneFrom != null)
                {
                    return this.cloneFrom.NextPageText;
                }
                object obj2 = this.ViewState["NextPageText"];
                if (obj2 != null)
                {
                    return (string) obj2;
                }
                return "&gt;";
            }
            set
            {
                this.ViewState["NextPageText"] = value;
            }
        }

        [DefaultValue(10), XDescription("desc_NumericButtonCount"), Browsable(true), XCategory("cat_Navigation"), Themeable(true)]
        public int NumericButtonCount
        {
            get
            {
                if (this.cloneFrom != null)
                {
                    return this.cloneFrom.NumericButtonCount;
                }
                object obj2 = this.ViewState["NumericButtonCount"];
                if (obj2 != null)
                {
                    return (int) obj2;
                }
                return 10;
            }
            set
            {
                this.ViewState["NumericButtonCount"] = value;
            }
        }

        [DefaultValue(""), Browsable(true), XCategory("cat_Navigation"), XDescription("desc_NBTFormatString"), Themeable(true)]
        public string NumericButtonTextFormatString
        {
            get
            {
                if (this.cloneFrom != null)
                {
                    return this.cloneFrom.NumericButtonTextFormatString;
                }
                object obj2 = this.ViewState["NumericButtonTextFormatString"];
                if (obj2 != null)
                {
                    return (string) obj2;
                }
                return string.Empty;
            }
            set
            {
                this.ViewState["NumericButtonTextFormatString"] = value;
            }
        }

        [DefaultValue(0), Browsable(true), XCategory("cat_Navigation"), XDescription("desc_NumericButtonType"), Themeable(true)]
        public PagingButtonType NumericButtonType
        {
            get
            {
                if (this.cloneFrom != null)
                {
                    return this.cloneFrom.NumericButtonType;
                }
                object obj2 = this.ViewState["NumericButtonType"];
                if (obj2 != null)
                {
                    return (PagingButtonType) obj2;
                }
                return this.PagingButtonType;
            }
            set
            {
                this.ViewState["NumericButtonType"] = value;
            }
        }

        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Browsable(false)]
        public int PageCount
        {
            get
            {
                if (this.RecordCount == 0)
                {
                    return 1;
                }
                return (int) Math.Ceiling((double) (((double) this.RecordCount) / ((double) this.PageSize)));
            }
        }

        [XDescription("desc_PageIndexBoxClasss"), DefaultValue((string) null), Browsable(true), XCategory("cat_PageIndexBox")]
        public string PageIndexBoxClass
        {
            get
            {
                if (this.cloneFrom != null)
                {
                    return this.cloneFrom.PageIndexBoxClass;
                }
                object obj2 = this.ViewState["PageIndexBoxClass"];
                if (obj2 != null)
                {
                    return (string) obj2;
                }
                return null;
            }
            set
            {
                if (value.Trim().Length > 0)
                {
                    this.ViewState["PageIndexBoxClass"] = value;
                }
            }
        }

        [DefaultValue((string) null), XDescription("desc_PageIndexBoxStyle"), XCategory("cat_PageIndexBox"), Browsable(true)]
        public string PageIndexBoxStyle
        {
            get
            {
                if (this.cloneFrom != null)
                {
                    return this.cloneFrom.PageIndexBoxStyle;
                }
                object obj2 = this.ViewState["PageIndexBoxStyle"];
                if (obj2 != null)
                {
                    return (string) obj2;
                }
                return null;
            }
            set
            {
                if (value.Trim().Length > 0)
                {
                    this.ViewState["PageIndexBoxStyle"] = value;
                }
            }
        }

        [XDescription("desc_PageIndexBoxType"), DefaultValue((string) null), Browsable(true), XCategory("cat_PageIndexBox")]
        public PageIndexBoxType PageIndexBoxType
        {
            get
            {
                if (this.cloneFrom != null)
                {
                    return this.cloneFrom.PageIndexBoxType;
                }
                object obj2 = this.ViewState["PageIndexBoxType"];
                if (obj2 != null)
                {
                    return (PageIndexBoxType) obj2;
                }
                return PageIndexBoxType.TextBox;
            }
            set
            {
                this.ViewState["PageIndexBoxType"] = value;
            }
        }

        [XDefaultValue("def_PIOutOfRangerMsg"), XDescription("desc_PIOutOfRangeMsg"), Category("Data"), Browsable(true), Themeable(true)]
        public string PageIndexOutOfRangeErrorMessage
        {
            get
            {
                object obj2 = this.ViewState["PIOutOfRangeErrorMsg"];
                if (obj2 != null)
                {
                    return (string) obj2;
                }
                if (this.cloneFrom != null)
                {
                    return this.cloneFrom.PageIndexOutOfRangeErrorMessage;
                }
                return ResReader.GetString("def_PIOutOfRangerMsg");
            }
            set
            {
                this.ViewState["PIOutOfRangeErrorMsg"] = value;
            }
        }

        [Browsable(true), DefaultValue(10), XDescription("desc_PageSize"), XCategory("cat_Paging")]
        public int PageSize
        {
            get
            {
                int num;
                if ((!string.IsNullOrEmpty(this.UrlPageSizeName) && !base.DesignMode) && (int.TryParse(this.Page.Request.QueryString[this.UrlPageSizeName], out num) && (num > 0)))
                {
                    return num;
                }
                if (this.cloneFrom != null)
                {
                    return this.cloneFrom.PageSize;
                }
                object obj2 = this.ViewState["PageSize"];
                if (obj2 != null)
                {
                    return (int) obj2;
                }
                return 10;
            }
            set
            {
                this.ViewState["PageSize"] = value;
            }
        }

        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Browsable(false)]
        public int PagesRemain
        {
            get
            {
                return (this.PageCount - this.CurrentPageIndex);
            }
        }

        [XDescription("desc_PagingButtonLayoutType"), Browsable(true), Themeable(true), DefaultValue(3), XCategory("cat_Navigation")]
        public PagingButtonLayoutType PagingButtonLayoutType
        {
            get
            {
                if (this.cloneFrom != null)
                {
                    return this.cloneFrom.PagingButtonLayoutType;
                }
                object obj2 = this.ViewState["PagingButtonLayoutType"];
                if (obj2 != null)
                {
                    return (PagingButtonLayoutType) obj2;
                }
                return PagingButtonLayoutType.None;
            }
            set
            {
                this.ViewState["PagingButtonLayoutType"] = value;
            }
        }

        [XDescription("desc_PagingButtonSpacing"), Themeable(true), XCategory("cat_Navigation"), DefaultValue(typeof(Unit), "5px"), Browsable(true)]
        public Unit PagingButtonSpacing
        {
            get
            {
                if (this.cloneFrom != null)
                {
                    return this.cloneFrom.PagingButtonSpacing;
                }
                object obj2 = this.ViewState["PagingButtonSpacing"];
                if (obj2 != null)
                {
                    return Unit.Parse(obj2.ToString());
                }
                return Unit.Pixel(5);
            }
            set
            {
                this.ViewState["PagingButtonSpacing"] = value;
            }
        }

        [Browsable(true), Themeable(true), XCategory("cat_Navigation"), XDescription("desc_PagingButtonType"), DefaultValue(0)]
        public PagingButtonType PagingButtonType
        {
            get
            {
                if (this.cloneFrom != null)
                {
                    return this.cloneFrom.PagingButtonType;
                }
                object obj2 = this.ViewState["PagingButtonType"];
                if (obj2 != null)
                {
                    return (PagingButtonType) obj2;
                }
                return PagingButtonType.Text;
            }
            set
            {
                this.ViewState["PagingButtonType"] = value;
            }
        }

        [Browsable(true), XDescription("desc_PrevPageText"), DefaultValue("&lt;"), Themeable(true), XCategory("cat_Navigation")]
        public string PrevPageText
        {
            get
            {
                if (this.cloneFrom != null)
                {
                    return this.cloneFrom.PrevPageText;
                }
                object obj2 = this.ViewState["PrevPageText"];
                if (obj2 != null)
                {
                    return (string) obj2;
                }
                return "&lt;";
            }
            set
            {
                this.ViewState["PrevPageText"] = value;
            }
        }

        [Category("Data"), DefaultValue(0), Browsable(false), XDescription("desc_RecordCount")]
        public int RecordCount
        {
            get
            {
                if (this.cloneFrom != null)
                {
                    return this.cloneFrom.RecordCount;
                }
                object obj2 = this.ViewState["Recordcount"];
                if (obj2 != null)
                {
                    return (int) obj2;
                }
                return 0;
            }
            set
            {
                this.ViewState["Recordcount"] = value;
            }
        }

        [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public int RecordsRemain
        {
            get
            {
                if (this.CurrentPageIndex < this.PageCount)
                {
                    return (this.RecordCount - (this.CurrentPageIndex * this.PageSize));
                }
                return 0;
            }
        }

        [Browsable(true), XDescription("desc_ReverseUrlPageIndex"), DefaultValue(false), XCategory("cat_Paging")]
        public bool ReverseUrlPageIndex
        {
            get
            {
                if (this.cloneFrom != null)
                {
                    return this.cloneFrom.ReverseUrlPageIndex;
                }
                object obj2 = this.ViewState["ReverseUrlPageIndex"];
                return ((obj2 != null) && ((bool) obj2));
            }
            set
            {
                this.ViewState["ReverseUrlPageIndex"] = value;
            }
        }

        [Browsable(true), DefaultValue(30), Themeable(true), XDescription("desc_ShowBoxThreshold"), XCategory("cat_PageIndexBox")]
        public int ShowBoxThreshold
        {
            get
            {
                if (this.cloneFrom != null)
                {
                    return this.cloneFrom.ShowBoxThreshold;
                }
                object obj2 = this.ViewState["ShowBoxThreshold"];
                if (obj2 != null)
                {
                    return (int) obj2;
                }
                return 30;
            }
            set
            {
                this.ViewState["ShowBoxThreshold"] = value;
            }
        }

		[Category("Appearance"), XDescription("desc_ShowCustomTip"), DefaultValue(0), Browsable(true), Themeable(true)]
		public ShowCustomTip ShowCustomTip
        {
            get
            {
                if (this.cloneFrom != null)
                {
                    return this.cloneFrom.ShowCustomTip;
                }
				object obj2 = this.ViewState["ShowCustomTip"];
                if (obj2 != null)
                {
                    return (ShowCustomTip) obj2;
                }
				return ShowCustomTip.Never;
            }
            set
            {
				this.ViewState["ShowCustomTip"] = value;
            }
        }

        [XCategory("cat_Navigation"), XDescription("desc_ShowDisabledButtons"), DefaultValue(true), Themeable(true), Browsable(true)]
        public bool ShowDisabledButtons
        {
            get
            {
                if (this.cloneFrom != null)
                {
                    return this.cloneFrom.ShowDisabledButtons;
                }
                object obj2 = this.ViewState["ShowDisabledButtons"];
                if (obj2 != null)
                {
                    return (bool) obj2;
                }
                return true;
            }
            set
            {
                this.ViewState["ShowDisabledButtons"] = value;
            }
        }

        [XCategory("cat_Navigation"), Themeable(true), Browsable(true), XDescription("desc_ShowFirstLast"), DefaultValue(true)]
        public bool ShowFirstLast
        {
            get
            {
                if (this.cloneFrom != null)
                {
                    return this.cloneFrom.ShowFirstLast;
                }
                object obj2 = this.ViewState["ShowFirstLast"];
                if (obj2 != null)
                {
                    return (bool) obj2;
                }
                return true;
            }
            set
            {
                this.ViewState["ShowFirstLast"] = value;
            }
        }

        [Browsable(true), Themeable(true), XCategory("cat_Navigation"), DefaultValue(false), XDescription("desc_ShowNavigationToolTip")]
        public bool ShowNavigationToolTip
        {
            get
            {
                if (this.cloneFrom != null)
                {
                    return this.cloneFrom.ShowNavigationToolTip;
                }
                object obj2 = this.ViewState["ShowNvToolTip"];
                return ((obj2 != null) && ((bool) obj2));
            }
            set
            {
                this.ViewState["ShowNvToolTip"] = value;
            }
        }

        [Themeable(true), XCategory("cat_Navigation"), DefaultValue(true), XDescription("desc_ShowPageIndex"), Browsable(true)]
        public bool ShowPageIndex
        {
            get
            {
                if (this.cloneFrom != null)
                {
                    return this.cloneFrom.ShowPageIndex;
                }
                object obj2 = this.ViewState["ShowPageIndex"];
                if (obj2 != null)
                {
                    return (bool) obj2;
                }
                return true;
            }
            set
            {
                this.ViewState["ShowPageIndex"] = value;
            }
        }

        [XCategory("cat_PageIndexBox"), DefaultValue((string) null), XDescription("desc_ShowPageIndexBox"), Browsable(true)]
        public ShowPageIndexBox ShowPageIndexBox
        {
            get
            {
                if (this.cloneFrom != null)
                {
                    return this.cloneFrom.ShowPageIndexBox;
                }
                object obj2 = this.ViewState["ShowPageIndexBox"];
                if (obj2 != null)
                {
                    return (ShowPageIndexBox) obj2;
                }
                return ShowPageIndexBox.Auto;
            }
            set
            {
                this.ViewState["ShowPageIndexBox"] = value;
            }
        }

        [XCategory("cat_Navigation"), Themeable(true), XDescription("desc_ShowPrevNext"), DefaultValue(true), Browsable(true)]
        public bool ShowPrevNext
        {
            get
            {
                if (this.cloneFrom != null)
                {
                    return this.cloneFrom.ShowPrevNext;
                }
                object obj2 = this.ViewState["ShowPrevNext"];
                if (obj2 != null)
                {
                    return (bool) obj2;
                }
                return true;
            }
            set
            {
                this.ViewState["ShowPrevNext"] = value;
            }
        }

        public override string SkinID
        {
            get
            {
                if (this.cloneFrom != null)
                {
                    return this.cloneFrom.SkinID;
                }
                return base.SkinID;
            }
            set
            {
                base.SkinID = value;
            }
        }

        [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public int StartRecordIndex
        {
            get
            {
                return (((this.CurrentPageIndex - 1) * this.PageSize) + 1);
            }
        }

        [XDescription("desc_SubmitButtonClass"), DefaultValue((string) null), Browsable(true), XCategory("cat_PageIndexBox")]
        public string SubmitButtonClass
        {
            get
            {
                if (this.cloneFrom != null)
                {
                    return this.cloneFrom.SubmitButtonClass;
                }
                return (string) this.ViewState["SubmitButtonClass"];
            }
            set
            {
                this.ViewState["SubmitButtonClass"] = value;
            }
        }

        [Category("Appearance"), Browsable(true), DefaultValue(""), XDescription("desc_SubmitButtonImageUrl")]
        public string SubmitButtonImageUrl
        {
            get
            {
                if (this.cloneFrom != null)
                {
                    return this.cloneFrom.SubmitButtonImageUrl;
                }
                return (string) this.ViewState["SubmitButtonImageUrl"];
            }
            set
            {
                this.ViewState["SubmitButtonImageUrl"] = value;
            }
        }

        [Browsable(true), DefaultValue((string) null), XDescription("desc_SubmitButtonStyle"), XCategory("cat_PageIndexBox")]
        public string SubmitButtonStyle
        {
            get
            {
                if (this.cloneFrom != null)
                {
                    return this.cloneFrom.SubmitButtonStyle;
                }
                return (string) this.ViewState["SubmitButtonStyle"];
            }
            set
            {
                this.ViewState["SubmitButtonStyle"] = value;
            }
        }

        [Browsable(true), XCategory("cat_PageIndexBox"), DefaultValue("go"), XDescription("desc_SubmitButtonText"), Themeable(true)]
        public string SubmitButtonText
        {
            get
            {
                if (this.cloneFrom != null)
                {
                    return this.cloneFrom.SubmitButtonText;
                }
                object obj2 = this.ViewState["SubmitButtonText"];
                if (obj2 != null)
                {
                    return (string) obj2;
                }
                return "go";
            }
            set
            {
                if (value == null)
                {
                    value = "go";
                }
                this.ViewState["SubmitButtonText"] = value;
            }
        }

        [DefaultValue((string) null), XDescription("desc_TextAfterPageIndexBox"), Browsable(true), Themeable(true), XCategory("cat_PageIndexBox")]
        public string TextAfterPageIndexBox
        {
            get
            {
                if (this.cloneFrom != null)
                {
                    return this.cloneFrom.TextAfterPageIndexBox;
                }
                object obj2 = this.ViewState["TextAfterPageIndexBox"];
                if (obj2 != null)
                {
                    return (string) obj2;
                }
                return null;
            }
            set
            {
                this.ViewState["TextAfterPageIndexBox"] = value;
            }
        }

        [XDescription("desc_TextBeforePageIndexBox"), Browsable(true), Themeable(true), XCategory("cat_PageIndexBox"), DefaultValue((string) null)]
        public string TextBeforePageIndexBox
        {
            get
            {
                if (this.cloneFrom != null)
                {
                    return this.cloneFrom.TextBeforePageIndexBox;
                }
                object obj2 = this.ViewState["TextBeforePageIndexBox"];
                if (obj2 != null)
                {
                    return (string) obj2;
                }
                return null;
            }
            set
            {
                this.ViewState["TextBeforePageIndexBox"] = value;
            }
        }

        [XDescription("desc_UrlPageIndexName"), DefaultValue("page"), Browsable(true), XCategory("cat_Paging")]
        public string UrlPageIndexName
        {
            get
            {
                if (this.cloneFrom != null)
                {
                    return this.cloneFrom.UrlPageIndexName;
                }
                object obj2 = this.ViewState["UrlPageIndexName"];
                if (obj2 != null)
                {
                    return (string) obj2;
                }
                return "page";
            }
            set
            {
                this.ViewState["UrlPageIndexName"] = value;
            }
        }

        [Browsable(true), XCategory("cat_Paging"), XDescription("desc_UrlPageSizeName"), DefaultValue("")]
        public string UrlPageSizeName
        {
            get
            {
                if (this.cloneFrom != null)
                {
                    return this.cloneFrom.UrlPageSizeName;
                }
                return (string) this.ViewState["UrlPageSizeName"];
            }
            set
            {
                this.ViewState["UrlPageSizeName"] = value;
            }
        }

        [XDescription("desc_UrlPaging"), DefaultValue(false), Browsable(true), XCategory("cat_Paging")]
        public bool UrlPaging
        {
            get
            {
                if (this.cloneFrom != null)
                {
                    return this.cloneFrom.UrlPaging;
                }
                object obj2 = this.ViewState["UrlPaging"];
                return ((obj2 != null) && ((bool) obj2));
            }
            set
            {
                this.ViewState["UrlPaging"] = value;
            }
        }

        [Browsable(true), DefaultValue(""), XCategory("cat_Navigation"), XDescription("desc_UrlPagingTarget"), TypeConverter(typeof(TargetConverter)), Themeable(true)]
        public string UrlPagingTarget
        {
            get
            {
                if (this.cloneFrom != null)
                {
                    return this.cloneFrom.UrlPagingTarget;
                }
                return (string) this.ViewState["UrlPagingTarget"];
            }
            set
            {
                this.ViewState["UrlPagingTarget"] = value;
            }
        }

        [Category("Behavior"), Themeable(true), Browsable(true), DefaultValue((string) null), XDescription("desc_UrlRewritePattern")]
        public string UrlRewritePattern
        {
            get
            {
                object obj2 = this.ViewState["URPattern"];
                if (obj2 != null)
                {
                    return (string) obj2;
                }
                if (this.cloneFrom != null)
                {
                    return this.cloneFrom.UrlRewritePattern;
                }
                if (this.EnableUrlRewriting && !base.DesignMode)
                {
                    string filePath = this.Page.Request.FilePath;
                    return (Path.GetFileNameWithoutExtension(filePath) + "_{0}" + Path.GetExtension(filePath));
                }
                return null;
            }
            set
            {
                this.ViewState["URPattern"] = value;
            }
        }

        public override bool Wrap
        {
            get
            {
                return base.Wrap;
            }
            set
            {
                base.Wrap = false;
            }
		}
		#endregion
	}
}

